Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share the additional container storage #766

Merged

Conversation

fabiendupont
Copy link
Contributor

@fabiendupont fabiendupont commented Aug 22, 2024

We need to share container image storage between rootless users, so that
we don't need sudo and we don't duplicate the instructlab image.
This change follows the Red Hat solution to
create additional image store for rootless users.

The /usr/lib/containers/storage folder can be read by anyone and new
users will inherit a default configuration via /etc/skel that
configures the additional storage.

The ilab wrapper is also modified to remove the impersonation code and
not use sudo anymore.

@fabiendupont
Copy link
Contributor Author

/cc @n1hility, @eranco74, @omertuc, @kwozyman

Copy link
Contributor

@eranco74 eranco74 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this approach, just need to sort out the permissions.
If we allow only read access we should add an additional storage path where users may write to.

skip_mount_home = ""
mount_program = "/usr/bin/fuse-overlayfs"
mountopt = ""
additionalimagestores = [ "/usr/lib/containers/storage",]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to allow non-root users access (at lest read) to this path.
Probably need to sort out selinux as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The read access is set in the Containerfile. We could limit to a specific group, too.

@@ -191,6 +191,9 @@ RUN --mount=type=secret,id=${INSTRUCTLAB_IMAGE_PULL_SECRET}/.dockerconfigjson \
else \
IID=$(sudo podman --root /usr/lib/containers/storage pull ${INSTRUCTLAB_IMAGE}); \
fi
chmod -R a+rx /usr/lib/containers/storage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was our original approach but we abandoned it because this makes all the files even inside the container executable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could refine with find to put the x only on the folders. Would that be better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was this suggestion but I never tried it, IDK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgwalters's suggestion to use chmod a+rX is nice. It will avoid adding x permission to config files or example scripts.

@fabiendupont fabiendupont force-pushed the nvidia-bootc-shared-container-storage branch 2 times, most recently from 92e156a to 90216f7 Compare August 29, 2024 07:39
@fabiendupont fabiendupont force-pushed the nvidia-bootc-shared-container-storage branch 2 times, most recently from aa66e5d to 857b513 Compare August 29, 2024 14:18
@fabiendupont fabiendupont marked this pull request as ready for review August 29, 2024 14:19
@fabiendupont fabiendupont marked this pull request as draft August 30, 2024 09:29
@fabiendupont fabiendupont marked this pull request as ready for review September 2, 2024 07:42
@fabiendupont
Copy link
Contributor Author

/cc @n1hility @rhatdan @cgwalters

@rhatdan
Copy link
Member

rhatdan commented Sep 3, 2024

@giuseppe PTAL

@@ -190,7 +190,10 @@ RUN --mount=type=secret,id=${INSTRUCTLAB_IMAGE_PULL_SECRET}/.dockerconfigjson \
IID=$(sudo podman --root /usr/lib/containers/storage pull --authfile /run/secrets/${INSTRUCTLAB_IMAGE_PULL_SECRET}/.dockerconfigjson ${INSTRUCTLAB_IMAGE}); \
else \
IID=$(sudo podman --root /usr/lib/containers/storage pull ${INSTRUCTLAB_IMAGE}); \
fi
fi && \
chmod -R a+rX /usr/lib/containers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you also setting force_mask=shared in the storage.conf file?

If you do so, then podman will store the original permissions in an extended attribute, that it is used by fuse-overlays

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, it is not set. Should it be in the global storage.conf or it could be in the user config?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the delay.

It must be in the configuration file for the user that is creating the storage (i.e. runs podman pull). Also, when using --root, it tells Podman to ignore any other setting from the storage.conf, so in this case, it must be provided on the command line as a --storage-opt overlay.force_mask=shared

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @giuseppe. I updated the user storage.conf template and the Containerfile. Would you mind reviewing again, please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that bootc does not preserve these extended arguments, you will lose them

We need to share container image storage between rootless users, so that
we don't need `sudo` and we don't duplicate the `instructlab` image.
This change follows the Red Hat solution to
[create additional image store for rootless users](https://access.redhat.com/solutions/6206192).

The `/usr/lib/containers/storage` folder can be read by anyone and new
users will inherit a default configuration via `/etc/skel` that
configures the additional storage.

The `ilab` wrapper is also modified to remove the impersonation code and
not use `sudo` anymore.

Signed-off-by: Fabien Dupont <[email protected]>
@fabiendupont fabiendupont force-pushed the nvidia-bootc-shared-container-storage branch from 857b513 to fe98baf Compare September 18, 2024 15:14
@rhatdan
Copy link
Member

rhatdan commented Sep 18, 2024

@giuseppe PTANL

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -190,7 +190,10 @@ RUN --mount=type=secret,id=${INSTRUCTLAB_IMAGE_PULL_SECRET}/.dockerconfigjson \
IID=$(sudo podman --root /usr/lib/containers/storage pull --authfile /run/secrets/${INSTRUCTLAB_IMAGE_PULL_SECRET}/.dockerconfigjson ${INSTRUCTLAB_IMAGE}); \
else \
IID=$(sudo podman --root /usr/lib/containers/storage pull ${INSTRUCTLAB_IMAGE}); \
fi
fi && \
chmod -R a+rX /usr/lib/containers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM

@rhatdan
Copy link
Member

rhatdan commented Sep 18, 2024

@fabiendupont still something we want to merge? Will this work well with rootful containers as well, without using fuse-overlay?

@fabiendupont
Copy link
Contributor Author

@rhatdan, yes, that's still something we want to merge. It removes the requirement to use sudo, so it's a step in the right direction.
IIUC, the rootful containers shouldn't be impacted. The overlay config only applies to standard users and the instructlab container that is loaded during the build. If someone adds container images via layering, the won't be readable by users, unless the chmod -R a+X command is run again.

@rhatdan
Copy link
Member

rhatdan commented Sep 18, 2024

LGTM

@rhatdan rhatdan merged commit 375d8c8 into containers:main Sep 18, 2024
1 check passed
fabiendupont added a commit to fabiendupont/ai-lab-recipes that referenced this pull request Sep 27, 2024
We need to share container image storage between rootless users, so that
we don't need `sudo` and we don't duplicate the `instructlab` image.
This change follows the Red Hat solution to
[create additional image store for rootless
users](https://access.redhat.com/solutions/6206192).

The `/usr/lib/containers/storage` folder can be read by anyone and new
users will inherit a default configuration via `/etc/skel` that
configures the additional storage.

The `ilab` wrapper is also modified to remove the impersonation code and
not use `sudo` anymore.

Follow-up on containers#766

Signed-off-by: Fabien Dupont <[email protected]>
fabiendupont added a commit to fabiendupont/ai-lab-recipes that referenced this pull request Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants